#include <cstdint>
#include <ios>
#include <iostream>

using ll = int64_t;
const ll md[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll m,d;
    char c;
    std::cin>>m>>c>>d;
    if(12<m || m<1){
        if(1<=d && d<=28){
            std::cout<<"1\n";
        }else{
            if(m<20){
                if(1<=d && d<=31){
                    std::cout<<"1\n";
                }else{
                    std::cout<<"2\n";
                }
            }else{
                if(m%10<=2){
                    std::cout<<"1\n";
                }else{
                    if(1<=d && d<=md[m%10]){
                        std::cout<<"1\n";
                    }else{
                        std::cout<<"2\n";
                    }
                }
            }
        }
    }else if(1<=d && d<=md[m]){
        std::cout<<"0\n";
    }else{
        std::cout<<"1\n";
    }
}